{include file="public/adminhead"}

<div class="container-fluid p-t-15">
  
  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-body">

          <form class="form-horizontal" action="#" method="post" enctype="multipart/form-data" onsubmit="return false;">
            {notempty name='$res'}<input type="hidden" name="id" value="{$res.id}">{/notempty}
            <div class="form-group has-success">
              <label class="col-xs-12" for="example-text-input-success">名称</label>
              <div class="col-xs-12">
                <input class="form-control" type="text"
                       id="example-text-input-success"
                       name="name" placeholder="请输入"
                       {notempty name='$res'}value="{$res.name}"{/notempty}
                >
              </div>
            </div>

            <div class="form-group has-success">
              <label class="col-xs-12" for="example-text-input-success">链接</label>
              <div class="col-xs-12">
                <input class="form-control" type="text"
                       name="link" placeholder="请输入 http:开头"
                       {notempty name='$res'}value="{$res.link}"{/notempty}
                >
              </div>
            </div>

            <div class="form-group has-success">
              <label class="col-xs-12" for="example-text-input-success">别名</label>
              <div class="col-xs-12">
                <input class="form-control" type="text"
                       name="alias" placeholder="请输入"
                       {notempty name='$res'}value="{$res.alias}"{/notempty}
                >
              </div>
            </div>


            <div class="form-group has-success">
              <label class="col-xs-12" for="example-text-input-success">排序</label>
              <div class="col-xs-12">
                <input class="form-control" type="text"
                       name="ordid" placeholder="请输入"
                       {notempty name='$res'}value="{$res.ordid}"{/notempty}
                >
              </div>
            </div>


            <div class="form-group">
              <label class="col-xs-12" for="example-select">父级</label>
              <div class="col-xs-12">
                <select class="form-control" id="example-select" name="pid" size="1">
                  <option value="0">顶级</option>
                  {notempty name='$res'}
                  {foreach $handle_list as $v}
                  <option {if $res.pid == $v.id}selected="selected"{/if} value="{$v.id}">{$v.name}</option>
                  {/foreach}
                  {else/}
                  {foreach $handle_list as $v}
                  <option value="{$v.id}">
                    {if $v.level > 1}
                    {for start="1" end="$v.level * 2"}
                    &nbsp;
                    {/for}
                    {/if}
                    {$v.name}
                  </option>
                  {/foreach}
                  {/notempty}
                </select>
              </div>
            </div>

            <div class="form-group">
              <label class="col-xs-12" >类型</label>
              <div class="col-xs-12">
                <select class="form-control" name="type" size="1">
                  <option value="nav_top"
                          {notempty name='$res'}{if $res.type== 'nav_top'} selected="selected"{/if}{/notempty}
                  >顶部小导航条</option>
                  <option value="top"
                          {notempty name='$res'}{if $res.type== 'top'} selected="selected"{/if}{/notempty}
                  >顶级</option>
                  <option value="main"
                          {notempty name='$res'}{if $res.type== 'main'} selected="selected"{/if}{/notempty}
                  >中部</option>
                  <option value="bottom"
                          {notempty name='$res'}{if $res.type== 'bottom'} selected="selected"{/if}{/notempty}
                  >低部</option>
                </select>
              </div>
            </div>

            <div class="form-group has-success">
              <label class="col-xs-12" for="example-text-input-success">新窗口打开</label>
              <div class="col-xs-12">
                <div class="example-box">
                  <label class="lyear-radio radio-inline radio-primary">
                    <input
                            {notempty name='$res'}{if $res.target ==1}checked="checked"{/if}{/notempty}
                            type="radio" name="target" value="on"><span>启用</span>
                  </label>
                  <label class="lyear-radio radio-inline radio-primary">
                    <input
                            {notempty name='$res'}{if $res.target ==0}checked="checked"{/if}{/notempty}
                            type="radio" name="target" value="off"><span>禁用</span>
                  </label>
                </div>
              </div>
            </div>

            <div class="form-group has-success">
              <label class="col-xs-12" for="example-text-input-success">启用</label>
              <div class="col-xs-12">
                <div class="example-box">
                  <label class="lyear-radio radio-inline radio-primary">
                    <input
                            {notempty name='$res'}{if $res.status ==1}checked="checked"{/if}{/notempty}
                            type="radio" name="status" value="on"><span>启用</span>
                  </label>
                  <label class="lyear-radio radio-inline radio-primary">
                    <input
                            {notempty name='$res'}{if $res.status ==0}checked="checked"{/if}{/notempty}
                            type="radio" name="status" value="off"><span>禁用</span>
                  </label>
                </div>
              </div>
            </div>

            <div class="form-group">
              <div class="col-xs-12">
                <button class="btn btn-primary" type="button" id="submit">提交</button>
              </div>
            </div>
          </form>

        </div>
      </div>
    </div>
    </div>
  </div>
  
</div>
{include file="public/afooter"}

<script>
  $("#submit").click(function () {
    var data = $("form").serialize();
    var url = "{:url('save')}"
    $.post(url,data,function (e) {
      if(e.code != 200){
        error(e.msg);
      }else {
        success(e.msg);
        var index = parent.layer.getFrameIndex(window.name);
        setTimeout(function(){parent.layer.close(index)}, 1000);
        window.parent.location.reload();
      }
    })
  })
</script>